
#pragma once

#include <istream>
#include <string>
#include <map>
#include "ValueItem.h"

namespace FlameEngine
{
	class ConfigItem
	{
	public:
		ConfigItem(std::shared_ptr<UniqueString>& name,DataFormat fmt, int16_t NumericElementCount);
		~ConfigItem();

		const std::shared_ptr<UniqueString>& GetName{ return m_name; }
		
		DataFormat GetDataFormat(){ return m_dataFormat; }

		const ValueType128& GetNumericValue(){ return m_value; }

		const std::string& GetStringValue(){ return m_strValue; }

		void SetNumericValue(ValueType128 value)
		{

		}

		void SetString(std::string* pStr)
		{

		}

		bool IsEqual(ConfigItem& other);
		
	private:
		std::shared_ptr<UniqueString> m_name;
		std::string m_strValue;
		ValueType128 m_value;
		DataFormat m_dataFormat;
		uint16_t   m_elementNum;
	};

	class ConfigCatalog
	{
		std::shared_ptr<UniqueString> m_name;
		std::unordered_map<uint32_t, ConfigItem> m_configs;
	};

	class ConfigTable
	{
	public:
		ConfigCatalog& GetConfigCatalog(const std::shared_ptr<UniqueString>& catalogName);
		bool RemoveCatalog(const std::shared_ptr<UniqueString>& catalogName);
		void RemoveAllCatalog();

		typedef std::vector<ConfigCatalog>::iterator iterator;
		typedef std::vector<ConfigCatalog>::const_iterator const_iterator;

		iterator begin(){ return m_configCatalogs.begin(); }
		const_iterator cbegin(){ return m_configCatalogs.cbegin(); }
	
		iterator end(){ return m_configCatalogs.end(); }
		const_iterator cend{ return m_configCatalogs.cend(); }

		size_t GetCatalogNum{ return m_configCatalogs.size(); }

		ConfigCatalog& GetGameWindowConfig();
		ConfigCatalog& GetGraphicsConfig();
		ConfigCatalog& GetSoundConfig();
		ConfigCatalog& GetGamePlayConfig();
		ConfigCatalog& GetNetworkConfig();

	private:
		std::vector<ConfigCatalog> m_configCatalogs;

		/*
		std::shared_ptr<UniqueString> m_window;
		std::shared_ptr<UniqueString> m_graphics;
		std::shared_ptr<UniqueString> m_sound;
		std::shared_ptr<UniqueString> m_gamePlay;
		std::shared_ptr<UniqueString> m_network;
		*/
	};
}